<template>
  <div class="container">
    <DataList
      ref="dataList"
      :propAutoFetchData="true"
      :propNoCheck="true"
      :propSearchFields="['loginKey','nickname','openId']"
      :propSearchTextAppend="'登录账号/用户名/openid'"
      propUrl="/base/userwx/pageCommon"
      showFieldPk="id"
      :isOnlyShow="true"
      :showFieldList="showFieldList"
      :vanFieldLabelWith5="true"
      :showDataFmtFun="showDataFmtFun"
      :sortDefault="{field: 'loginKey',type: 'asc'}"
    >
    </DataList>
  </div>
</template>

<script>

export default {
  help: '微信用户-列表',
  data() {
    return {
      activeNames: ['1'],
      showFieldList: [
        {label:'用户',name:'nickname',span:24, isTitle: true},
        {label:'登录账号',name:'loginKey',span:24, isTitleSub: true},
        {label:'openid',name:'openId',span:24},
        {
          label: '默认账号', name: 'flagDefault', span: 24, flagBoolean: true,
          queryType: this.constCommon.formItemType.switch.name,
          queryConfig: {
            options: this.constCommon.nobusConst.yesNoNumber
          }
        }
      ]
    }
  },

  methods: {
    showDataFmtFun(data) {
      data.forEach(item => {
        if ([1,true].includes(item.flagDefault)) {
          item.flagDefault = '1'
        } else{
          item.flagDefault = '0'
        }
      })
      return data
    }
  }
}
</script>
